/**
 * Dear programmer:
 * When I wrote this code, only god and I knew how it worked.
 * Now, only god knows it!
 *
 * @author: Pegasus  Date: 2018-12-13 Time: 22:23
 *
 * 我的工单
 */

import React, {Component} from 'react';
import {
    SafeAreaView,
    View,
    Text,
    Image,
    TouchableOpacity,
    ScrollView,
    Modal, ToastAndroid
} from 'react-native';
import {connect} from 'react-redux';
import {COLOR_WHITE} from "../../constant/PHColors"
import {styles} from './RoomOrderScreen.Style'
import ImageAndTextCellView from "../../component/ImageAndTextCellView/ImageAndTextCellView"
import DividingLineViewComponent from "../../component/DividingLineViewComponent/DividingLineViewComponent"
import {FetchStatus} from "../../configuration/RequestConfiguration";
import {ReturnStatus} from "../../configuration/ReturnStatus";
import {doDisplayWarnMessage} from "../../component/Message/Action";
import User from "../../model/User/User";

class RoomOrderScreen extends Component {

    static navigationOptions = ({navigation}) => ({
        headerTitle: `房务`,
    });

    // 构造
    constructor(props) {
        super(props);
        // 初始状态
        this.state = {
            RecordSummary:{},
        };
    }

    render() {
        return (
            <SafeAreaView style={styles.body}>

                <ScrollView style={styles.body}>

                    <View style={styles.headerContainer}>
                        <Text style={styles.headerText}>
                            房务
                        </Text>
                    </View>



                    <TouchableOpacity id={'btnStaffSchedule'} activeOpacity={0.8} onPress={() => {

                        User.getButtonRight(buttonRight=>{
                            if (buttonRight && buttonRight.buttonRight) {
                                let buttonRight_arr = JSON.parse(buttonRight.buttonRight)
                                let ifEnter = 0
                                for(let i = 0;i<buttonRight_arr.length;i++){
                                    if(buttonRight_arr[i].button==="btnStaffSchedule" && ( buttonRight_arr[i].jsp==='RoomOrderScreen' || buttonRight_arr[i].jsp==='*' )){
                                        ifEnter = 1
                                    }
                                }
                                if(ifEnter===0){
                                    this.props.navigation.navigate('StaffSchedule')
                                }else{
                                    ToastAndroid.show('无设置员工班表权限',1000)
                                }
                            }
                        })
                        // this.props.navigation.navigate('StaffSchedule')
                    }}>
                        <ImageAndTextCellView title={'员工班表'} />
                    </TouchableOpacity>

                    <DividingLineViewComponent lineHeight={1}/>

                    <TouchableOpacity id={'distributeRoom'} activeOpacity={0.8} onPress={() => {
                        User.getButtonRight(buttonRight=>{
                            if (buttonRight && buttonRight.buttonRight) {
                                let buttonRight_arr = JSON.parse(buttonRight.buttonRight)
                                let ifEnter = 0
                                for(let i = 0;i<buttonRight_arr.length;i++){
                                    if(buttonRight_arr[i].button==="distributeRoom" && ( buttonRight_arr[i].jsp==='RoomOrderScreen' || buttonRight_arr[i].jsp==='*' )){
                                        ifEnter = 1
                                    }
                                }
                                if(ifEnter===0){
                                    this.props.navigation.navigate('AssignRoom',{callBack:()=>{
                                        this.props.navigation.navigate('RoomOrderScreen');
                                    }})
                                }else{
                                    ToastAndroid.show('无分配做房权限',1000)
                                }
                            }
                        })


                    }}>
                        <ImageAndTextCellView title={'分配做房'} />
                    </TouchableOpacity>





                    <View style={styles.headerContainer}>
                        <Text style={styles.headerText}>
                            更多
                        </Text>
                    </View>

                    <TouchableOpacity activeOpacity={0.8} onPress={() => {
                        this.props.navigation.navigate('ContactsScreen')
                    }}>
                        <ImageAndTextCellView title={'通讯录'} />
                    </TouchableOpacity>

                    <DividingLineViewComponent lineHeight={1}/>

                    <TouchableOpacity activeOpacity={0.8} onPress={() => {
                        this.props.navigation.navigate('roomChangeReport')
                    }}>
                        <ImageAndTextCellView title={'换房报表'} />
                    </TouchableOpacity>

                    <DividingLineViewComponent lineHeight={1}/>

                    <TouchableOpacity activeOpacity={0.8} onPress={() => {
                        this.props.navigation.navigate('PersonnelStatusScreen')
                    }}>
                        <ImageAndTextCellView title={'人员状态'} />
                    </TouchableOpacity>

                    {/*<TouchableOpacity activeOpacity={0.8} onPress={() => {*/}
                        {/*User.getUser(user => {*/}
                            {/*if (user && user.token) {*/}
                                {/*this.props.navigation.navigate('ImmediateOrderScreen',{"status":"","condition":{"work_userid":"","create_user":user.userid},})*/}
                            {/*}*/}
                        {/*})*/}

                    {/*}}>*/}
                        {/*<ImageAndTextCellView title={'我创建的工单'}/>*/}
                    {/*</TouchableOpacity>*/}


                </ScrollView>


            </SafeAreaView>
        )
    }


}

const props = state => {
    return {

    }
}

export default RoomOrderScreen = connect(props)(RoomOrderScreen);